﻿#region 命名空间

using System;
using System.Web.UI.WebControls;
using WinnerCMS.BLL;
using WinnerCMS.Common;
using WinnerCMS.Model;

#endregion

namespace WinnerCMS.WebUI.Admin.Member
{
    public partial class Message_Send : WebFactory.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.BC_Path.Items.Add(new ListItem {Text = "会员中心", Value = "Member.aspx"});
                this.BC_Path.Items.Add(new ListItem {Text = "短信管理", Value = "Message.aspx"});
                if (Request["Action"] != "SystemSend")
                {
                    this.trMembers.Visible = true;
                    this.trCloseTime.Visible = false;
                    this.txtMembers.Text = Request["Users"];


                    this.BC_Path.Items.Add(new ListItem {Text = "发送短信", Value = ""});
                }
                else
                {
                    this.trCloseTime.Visible = true;
                    this.trMembers.Visible = false;
                    this.BC_Path.Items.Add(new ListItem {Text = "发送系统短信", Value = ""});
                }
            }
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            var model = new WinnerCMS.Model.Message
            {
                GUID = Guid.NewGuid().ToString(),
                Sender = UserManage.Current.UserName,
                Incept = this.txtMembers.Text.Trim(),
                Title = this.txtTitle.Text,
                Content = this.txtIntroduce.Text
            };

            var res = new MessageManage().Add(model);
            if (res.Errors.Length > 0)
            {
                MsgBox.Message(res.Errors, this);
            }
            else
            {
                MsgBox.Message("发送成功！", "Message.aspx", this);
            }
        }
    }
}